﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Interfaces;
using Utilities;
using System.Diagnostics;

namespace Accounts
{
   public class Account : IAccount
   {
      private static Logger logger_;
      private string sessionId_;
      private string userName_;
      private string encryptedPassword_;
      private string serverName_;

      ////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// 
      /// </summary>
      public Account()
      {
         logger_ = Program.Logger;
      }

      ////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// Implementation of IAccount
      /// </summary>
      public string SessionId { get { return sessionId_; } set { sessionId_ = value; } }

      ////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// Implementation of IAccount
      /// </summary>
      public string UserName { get { return userName_; } }

      ////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// Implementation of IAccount
      /// </summary>
      public string EncryptedPassword { get { return encryptedPassword_; } }

      ////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// Implementation of IAccount
      /// </summary>
      public string ServerName { get { return serverName_; } }

      ////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// IAccount method
      /// </summary>
      public bool Initialize(string userName, string encryptedPassword, string serverName)
      {
         try
         {
            userName_ = userName;
            encryptedPassword_ = encryptedPassword;
            serverName_ = serverName;
            return true;
         }
         catch (System.Exception ex)
         {
            logger_.Exception(ex);
         }
         return false;
      }

      ////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// IAccount method
      /// </summary>
      public void Shutdown()
      {
         sessionId_ = userName_ = encryptedPassword_ = serverName_ = null;
      }
   }
}
